﻿using Microsoft.Extensions.Configuration;
using ProTrack.IRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace ProTrack.Repository
{
    public class BaseConnection : IBaseConnection
    {
        public static ConnectionState State { get; internal set; }
        private SqlConnection Conn { get; set; }

        public void Dispose()
        {
            if (Conn != null)
            {
                Conn.Close();
            }

        }

        public SqlConnection GetConn()
        {
            var config = new ConfigurationBuilder()
                     .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                     .AddJsonFile("appsettings.json")
                     .Build();

            Conn = new SqlConnection(config.GetConnectionString("DefaultConnString"));
            return Conn;
        }
    }
}
